import 'dart:convert';
import 'paging_params.g.dart';

class PagingParams {
  int pageNum = 1;
  Map<String, dynamic>? extra = {};
  String? order = 'descending';
  int pageSize = 10;
  int? total;

  PagingParams();

  factory PagingParams.fromJson(Map<String, dynamic> json) =>
      $PagingParamsFromJson(json);

  Map<String, dynamic> toJson() => $PagingParamsToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }

  factory PagingParams.create(
      {required int pageIndex,
      int pageSize = 10,
      Map<String, dynamic>? model}) {
    var request = PagingParams();
    request.pageNum = pageIndex;
    request.pageSize = pageSize;

    return request;
  }
}
